package com.lmk.t02;

public class Test03 {
    public static void main(String[] args) {

        //1.通过字面常量创建字符串
        String s1="abc";
        //2.创建空的字符串
        String s2=new String();
        // 3.通过带参数的构造方法创建字符串：字符串
        String s3=new String("abc");
        //4.通过带参数的构造方法创建字符串：字符数组
        char[] sc={'a','b','c'};
        String s4=new String(sc);
        System.out.println(s4);
        //3.通过带参数的构造方法创建字符串：字节数组
        byte[]  bs={97,98,99};
        String s5=new String(bs);
        System.out.println(s5);
        //6.StringBuilder构建
        StringBuilder sb=new StringBuilder();
        sb.append("ab").append("cd");
        String s6=sb.toString();
        //7.  StringBuffer 构建
        StringBuffer sb2=new StringBuffer();
        sb2.append("ef").append("fg");
        String s7=sb2.toString();
        System.out.println(s7);
        String S8=s7;

    }
}
